<?php
class DataUserRegister{
	public $MailAddressBytes;
	public $PasswordHashBytes;
	public $SecretKeyBytes;
	function __construct(){
	}
	static function swap($bytebuffer){
		$user = new DataUserRegister();
		$user->MailAddressBytes = DataUtil::readBBin( $bytebuffer ) ;
		$user->PasswordHashBytes = DataUtil::readBBin( $bytebuffer ) ;
		$user->SecretKeyBytes = DataUtil::readBBin( $bytebuffer ) ;
		return $user;
	}
	function getPasswordHash(){
		return implode(array_map("chr",  $this->PasswordHashBytes )) ;
	}
	function setPasswordHash($hash){
		$this->PasswordHashBytes = unpack('C*', $hash ) ;
	}
	function getSecretKey(){
		return implode(array_map("chr",  $this->SecretKeyBytes )) ;
	}
	function getBinSize(){
		$size = 0;
		$size += 1  + count($this->MailAddressBytes);
		$size += 1  + count($this->PasswordHashBytes);
		$size += 1  + count($this->SecretKeyBytes);
		return $size;
	}
	function getBinary(){
		$buf = ByteBuffer::allocate( $this->getBinSize() ) ;
		DataUtil::writeBBin( $buf ,  $this->MailAddressBytes ) ;
		DataUtil::writeBBin( $buf ,  $this->PasswordHashBytes ) ;
		DataUtil::writeBBin( $buf ,  $this->SecretKeyBytes ) ;
		return  $buf ->_array() ;
	}
}
?>